package com.linkdood.app.schedule;

import com.linkdood.app.service.UploadFileService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * 定时任务删除本地过期文件
 *
 * @author xuxin
 */
@Slf4j
@Component
public class RemoveLocalFileTask extends QuartzJobBean {

    /**
     * 此处必须要使用 Autowired 或者 Setter， 不可以使用构造器
     */
    @Autowired
    private UploadFileService uploadFileService;

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) {
        // 删除过期文件
        log.info("Start delete expired file schedule task");
        uploadFileService.deleteInvalidFile();
        log.info("End delete expired file schedule task");
    }

}
